package com.fastmobile.util;

public class Util {

	/**
	 * Check a String is a Number
	 * @param value
	 * @return
	 */
//	public static boolean isNumber(String value) {
//		try {
//			Long.parseLong(value);
//		} catch (Exception e) {
//			return false;
//		}
//		return true;
//	}
	
	/**
	 * Check a String is a Number
	 * @param value
	 * @return
	 */
	public static boolean isNumber(String value) {
		if (null == value || value.isEmpty()) {
			return false;
		}
		int length = value.length();
		if (length >= Constant.NUMBER_MAX_LENGTH) {
			try {
				Long.parseLong(value);
			} catch (Exception e) {
				return false;
			}
		}
		
		int i = 0;
		if (value.charAt(0) == '-') {
			if (length > 1) {
				i++;
			} else {
				return false;
			}
		}
		
		
		for (; i < length; i++) {
			if (Character.isDigit(value.charAt(i))) {
				return false;
			}
		}
		return true;
	}
	
	public static boolean isNullOrBlank(Object value) {
		if (null != value) {
			return value.toString().isEmpty();
		}
		return true;
	}

}
